package com.situ.water_pay.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.situ.util.ResponseData;
import com.situ.water_pay.pojo.PyUserhistory;
import com.situ.water_pay.service.PyUserhistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@RestController
@RequestMapping("/py-userhistory")
public class PyUserhistoryController {
    @Autowired
    private PyUserhistoryService pyUserhistoryService;

    /**
     * 根据用户编号查询用户历史详单
     * @return
     */
    @GetMapping("/findByUserNo")
    public ResponseData findByUserNo(String UserNo) {
        try {
            QueryWrapper wrapper = new QueryWrapper();
            wrapper.eq("UserNo",UserNo);
            List<PyUserhistory> PyUserhistoryList = pyUserhistoryService.list(wrapper);
            return ResponseData.ok().putDataValue("PyUserhistoryList",PyUserhistoryList);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseData.Failure("查询用户历史详单失败");
        }
    }
}

